<?php

namespace fast;

/**
 * 车e估 接口对接
 */
class Ecar
{
    public $url = "http://open.cheegu.com";
    public $user = "wlcm";
    public $token = "8E4F8E02DCA844B589A5FE69C694CA1F";

    //品牌列表
    public function getMasterBrand($keyword)
    {
        $queryarr = [
            "token" => $this->token,
        ];
        if (!empty($keyword)) {
            $queryarr["keyword"] = $keyword;
        }
        $data = Http::get($this->url . "/CARDB.getMasterBrand", $queryarr);
        return json_decode($data, true)["message"];
    }

    //车系列表
    public function getSerial($masterid,$keyword)
    {
        $queryarr = [
            "token" => $this->token,
            "masterid" => $masterid,
        ];
        if (!empty($keyword)) {
            $queryarr["keyword"] = $keyword;
        }
        $data = Http::get($this->url . "/CARDB.getSerial", $queryarr);
        return json_decode($data, true)["message"];
    }

    //车型列表
    public function getModel($serialid,$keyword)
    {
        $queryarr = [
            "token" => $this->token,
            "serialid" => $serialid,
        ];
        if (!empty($keyword)) {
            $queryarr["keyword"] = $keyword;
        }
        $data = Http::get($this->url . "/CARDB.getModel", $queryarr);
        return json_decode($data, true)["message"];
    }

    //详细参数
    public function getModelDetail($modelid)
    {
        $queryarr = [
            "token" => $this->token,
            "modelid" => $modelid,
        ];
        $data = Http::get($this->url . "/CARDB.getModelDetail", $queryarr);
        return json_decode($data, true)["message"];
    }

    //详细配置
    public function getModelAllParameter($modelid)
    {
        $queryarr = [
            "token" => $this->token,
            "modelid" => $modelid,
        ];
        $data = Http::get($this->url . "/CARDB.getModelAllParameter", $queryarr);
        return json_decode($data, true)["message"];
    }


    //vin码定车型（精准高级版）
    public function getVIN($param)
    {
        $queryarr = [
            "vin" => $param,
        ];

        $data = Http::post($this->url . "/VINDB.checkList?token=".$this->token,$queryarr);
        return json_decode($data, true)["message"];
    }


    //行驶证识别
    public function getOCR($param)
    {

        $queryarr = [
            "imageUrl" => $param,
            "side" => 0,
        ];
        $data = Http::post($this->url . "/OCR.getVehicleLicense?token=".$this->token,$queryarr);
        return json_decode($data, true)["message"];
    }

}
